home *** CD-ROM | disk | FTP | other *** search
- Path: easy.in-chemnitz.de!mkmk!floh
- From: floh@mkmk.in-chemnitz.de (Andre Weissflog)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: include:clib/stdio_protos.h - where is it?
- Message-ID: <wMfky*sI0@mkmk.in-chemnitz.de>
- Date: Sat, 30 Mar 1996 13:46:08 CET
- Reply-To: floh@mkmk.in-chemnitz.de
- References: <354.6656T1088T147@mistral.co.uk> <4iIiy*XH0@mkmk.in-chemnitz.de>
- <1035.6658T1363T2026@mistral.co.uk>
- Distribution: world
- Organization: private uucp site
- X-Newsreader: Arn V 1.04
-
- In article <1035.6658T1363T2026@mistral.co.uk>, Adam Atkinson writes:
-
- > On 25-Mar-96 19:35:16, Andre Weissflog said:
- >
- > >I guess they mean <clib/alib_stdio_protos.h>. I would recommend
- > >*not* to use those functions unless you know exactly what you're
- > >doing, instead use the vanilla ANSI-stdio-functions that came
- > >with your compiler's c.lib, they are more powerful, and
- > >compatible with the rest of the ANSI file io stuff.
- >
- > Most people seem to have given me exactly the opposite advice. i.e. don't
- > mix ansi and amiga-specific stuff unless there is a good reason to. I'm
- > still feeling pretty lost, but my first 2 programs have compiled and work,
- > which is something.
- >
-
- Uhmm, yes, they are right, and my statement was possibly a bit
- too short...
-
- ANSI C specifies a few hundred support functions that cover stuff
- like file i/o, string manipulation, memory management etc etc
- etc... This is the common programming environment you can expect
- from any ANSI compiler on any machine in the galaxy (and possibly
- beyond). This programming environment is basically like a
- operating system on its own, however this "os" is always built
- on top of the native operating system of the machine (with the
- exception of elevator controllers maybe).
-
- AmigaOS offers hundreds of functions too, also covering stuff
- like memory management, file i/o etc...
-
- That's the reason why one should not mix ANSI style and AmigaOS
- style programming. It's certainly possible to some degree, but
- leads to unreadably code and what you get in the end are all the
- disadvantages of both worlds. One of the few exceptions are
- ANSI C's string manipulation functions, like strcpy(), because
- they have no AmigaOS equivalent.
-
- Thus: If you want to be sure your program compiles also on
- other systems, do it 100% ANSI C. It's completely fine to
- do console based programs that way on the Amiga, where you
- can go to the SGI next door and recompile and use it
- there without one change.
-
- If you want to write a program that makes use of the phantastic
- AmigaOS stuff, then go with the AmigaOS's functions as much
- as possible (and buy the ROM Kernel Reference Manuals please).
-
- Phew... now to alib_stio_protos.h:
-
- If you look at that file, you see those prototype definitions:
-
- LONG printf( STRPTR fmt, ... );
- LONG sprintf( STRPTR buffer, STRPTR fmt, ... );
- LONG fclose( long stream );
- LONG fgetc( long stream );
- LONG fprintf( long stream, STRPTR fmt, ... );
- LONG fputc( long c, long stream );
- LONG fputs( UBYTE *s, long stream );
- LONG getchar( void );
- LONG putchar( long c );
- LONG puts( BYTE *s );
-
- The names are clearly ANSI C, but the used datatypes are
- Amiga style. Those functions are neither clean ANSI C, nor
- AmigaOS. They encapsulate AmigaOS calls, but are "bastards" from
- the outside.
-
- Why C= ever created those functions probably only know the
- AmigaOS tribal elders. The only advantage one gets from using them
- is smaller programs (somewhere around 3..5 KByte smaller because
- shared library code is used and several startup initialisations
- are not needed). The main disadvantage is you can't mix them
- with all the other nice ANSI file i/o functions, because different
- file descriptors are used. And you must make sure to link amiga.lib
- before c.lib, or the linker will use the c.lib versions anyway.
-
- Everything clear now? :-)
-
- Bye,
- -Floh.
-
- ====//=== Andre Weissflog <floh@mkmk.in-chemnitz.de> =======
- ...//..........."Spirits in the material world"............
- \\//......90% of everything is crap (Sturgeon's Law)......
- =\\===============================================Amiga!=
-
-